﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StandardEdit.aspx.cs" Inherits="CNVP.JShop.Web.Admin.StandardEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="IE=7" http-equiv="X-UA-Compatible" />
    <link href="CSS/Edit.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/Single_Validator.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.js" type="text/javascript"></script>
    <script src="../Scripts/Common.js" type="text/javascript"></script>
    <script type ="text/javascript">
        $(function () {
            $("#btUp").click(function () {
                var $txtStandardName = $("#txtStandardName");
                if ($txtStandardName.val() == "") {
                    alert("请输入规格名称！");
                    $txtStandardName.focus();
                    return false;
                }
                var $txtStandardDetail = $("#txtStandardDetail");
                if ($txtStandardDetail.val().length > 2000) {
                    alert("备注过长，请不要超过2000字！");
                    $txtStandardDetail.focus();
                    return false;
                }
            });
        })
   </script>
   <script type="text/javascript">
       $(document).ready(function () {
           var i = 0;
           $("#BtAdd").click(function () {
               var $table = $("#tableEdit tr");
               var len = $table.length - 1 + "add";
               var j = $table.length - 1;
               //alert(len);
               var AddTr = "";
               AddTr += "<tr>";
               AddTr += "	<td class=\"CheckBoxEdit\" >" + j + "</td>";
               AddTr += "	<td class=\"CheckBoxEdit\">";
               AddTr += "		<input id=\"CK\" name=\"CK\" type=\"checkbox\"/><input id=\"CKStandard\" name=\"CKStandard\" type=\"checkbox\" checked=\"checked\" class =\"Display\"/></td>";
               AddTr += "	<td>";
               AddTr += "		<input id=\"StandardValueName" + len + "\" type=\"text\" name=\"StandardValueName\" maxlength=\"50\" /></td>";
               AddTr += "	<td >";
               AddTr += "		<input id=\"StandardValueOtherName" + len + "\" type=\"text\" name=\"StandardValueOtherName\" maxlength=\"50\" /></td>";
               AddTr += "	<td>";
               AddTr += "		<div class=\"ItemPic\">";
               AddTr += "			<img alt=\"\" src=\"Images/noPhoto.gif\" id=\"ImgStandardValuePic" + len + "\" width=\"50px\" height=\"50px\" onclick=\"SelectPic('" + len + "')\" style =\"cursor:pointer;\" />";
               AddTr += "			<input id=\"StandardValuePic" + len + "\" type=\"hidden\" name=\"StandardValuePic\" />";
               AddTr += "		</div>";
               AddTr += "		</td>";
               AddTr += "	<td>";
               AddTr += "		<input id=\"OrderID" + len + "\" type=\"text\" name=\"OrderID\" value=\"" + j + "\" /></td>";
               AddTr += "</tr>";
               $("#tableEdit").append(AddTr);
               StandardType();
           });
           $("#BtDel").click(function () {
               if (ifEditCheck()) {
                   if (confirm("你确定要删除！")) {
                       $("#tableEdit tr:gt(1)").each(function () {
                           if ($(this).find("#CK").get(0).checked == true) {
                               $(this).remove();
                           }
                       });
                   }
               }
               else {
                   alert('请选择记录！');
                   return false;
               }
           });
           $("#CKA").click(function () {
               $("#tableEdit tr:gt(1)").each(function () {
                   $(this).find("#CK").get(0).checked = $("#CKA").get(0).checked;
               });
           });

       });
       function SelectPic(index) {
           var Url = "CommonWindows/SValuePic_CommonWindow.aspx";
           var result = window.showModalDialog(encodeURI(Url), 'example04', 'dialogHeight:260px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable:yes;status:yes');
           if (result != null) {
               document.getElementById("ImgStandardValuePic" + index + "").src = result;
               document.getElementById("StandardValuePic" + index + "").value = result;
           }
       }
       function StandardType() {
           var rblStandardType = $("input[name='rblStandardType']:checked").val();
           if (rblStandardType == "1") {
               $(".TitlePic").css("display", "none");
               $(".ItemPic").css("display", "none");
           }
           else {
               //alert(rblStandardType);
               $(".TitlePic").css("display", "");
               $(".ItemPic").css("display", "");
           }
       }
     </script>
</head>
<body onload="StandardType();">
    <form id="form1" runat="server">
        <div class="Content">
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="cell">
            <tr>
                <td class="cell_group">
                    <img src="Images/ListIconTitle.jpg" alt="" />&nbsp;您的位置：<a href="StandardList.aspx">规格管理</a><asp:Label ID="lbTitle" runat="server"></asp:Label>
                </td>
            </tr>
            </table>
                <table border="0" cellpadding="0" cellspacing="0" class="division">
                        <tr>
                            <th>
                                 规格名称:</th>
                            <td>
                                 <asp:TextBox ID="txtStandardName" runat="server" MaxLength="100" />
                                </td>
                        </tr>
                        <tr class="Display" >
                            <th>
                                 显示方式:</th>
                            <td>
                                <asp:RadioButtonList ID="rblShowWay" runat="server" RepeatDirection="Horizontal" CssClass="RadioButtonListTable">
                                    <asp:ListItem Selected="True" Value="1">平铺显示</asp:ListItem>
                                    <asp:ListItem Value="2">下拉显示</asp:ListItem>
                                </asp:RadioButtonList>
                                </td>
                        </tr>
                        <tr>
                            <th>
                                别&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</th>
                            <td>
                                 <asp:TextBox ID="txtStandardOtherName" runat="server" MaxLength="50"/>
                                </td>
                        </tr> 
                         <tr>
                            <th>
                                显示类型:</th>
                            <td>
                                 <asp:RadioButtonList ID="rblStandardType" runat="server" RepeatDirection="Horizontal" Width="120px" CssClass="RadioButtonListTable">
                                    <asp:ListItem Selected="True" Value="1">文字</asp:ListItem>
                                    <asp:ListItem Value="2">图片</asp:ListItem>
                                </asp:RadioButtonList>
                                </td>
                        </tr> 
                        <tr>
                            <th>
                                备&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注:</th>
                            <td>
                                <asp:TextBox ID="txtStandardDetail" runat="server" Rows="5" 
                                    TextMode="MultiLine" Width="450px" />
                                </td>
                        </tr>
                </table>
                    <table id="tableEdit" border="0" cellpadding="0" cellspacing="0" class="division">
                       <tr>
                            <td colspan="6">
                                <input id="BtAdd" type="button" value="添加行" />&nbsp;<input id="BtDel" type="button" value="删除行" /></td>
                        </tr>
                        <tr>
                            <td class="CheckBoxEdit"></td>
                            <td class="CheckBoxEdit">
                                <input id="CKA" name="CKA" type="checkbox" /></td>
                            <td >
                                规格值名称(注：用&quot;|&quot;分割)</td>
                            <td >
                                规格值别名</td>
                            <td class="PicEdit">
                                <div class="TitlePic" style="display:none;">
                                    选择图片
                                </div>
                                </td>
                            <td >
                                排序</td>
                        </tr>
                        <asp:Repeater ID="rptList" runat="server">
                            <ItemTemplate>
                                 <tr>
                                    <td class="CheckBoxEdit"><%# Container.ItemIndex +1 %></td>
                                        <td class="CheckBoxEdit">
                                            <input id="CK" name="CK" type="checkbox" value='<%# Eval("ID")%>'  />
                                             <input id="CKStandard" name="CKStandard" type="checkbox" checked="checked" value='<%# Eval("ID")%>' class ="Display"/>
                                                
                                            </td>
                                        <td>
                                            <input id="StandardValueName" type="text" name="StandardValueName" value='<%# Eval("StandardValueName")%>' maxlength="50" /></td>
                                        <td >
                                            <input id="StandardValueOtherName" type="text" name="StandardValueOtherName" value='<%# Eval("StandardValueOtherName")%>' maxlength="50" /></td>
                                        <td>
                                            <div class="ItemPic" style="display:none;">
                                                <img alt="" src='<%# Eval("StandardValuePic").ToString() == "" ? "images/noPhoto.gif" : Eval("StandardValuePic")%>' id='ImgStandardValuePic<%# Eval("ID")%>' width="50px" height="50px" onclick='SelectPic(<%# Eval("ID")%>)' style="cursor:pointer"  />
                                                <input type ="hidden" id ='StandardValuePic<%# Eval("ID")%>' name ="StandardValuePic" value='<%# Eval("StandardValuePic")%>' />
                                            </div>
                                            </td>
                                        <td>
                                            <input id='OrderID' type="text" name="OrderID" value='<%# Eval("OrderID")%>' />
                                            </td>
                                    </tr>
                            </ItemTemplate>
                        </asp:Repeater>
                    </table>
                <div class="EditBtn">
                <asp:Button ID="btUp" runat="server" Text="提交" OnClick="btUp_Click" />
                 <input type="button" value="取消" onclick="javascript:history.go(-1)" />
                 </div>
        </div>
    </form>
</body>
</html>



